Ext.define('Demo.store.purchase.purchaseInquiryStore',{
	extend: 'Ext.data.Store',
	alias: 'widget.purchaseInquiryStore',
	model: 'Demo.model.purchase.purchaseInquiryModel',
	pageSize:1,
	autoLoad:true,
	proxy:{
		type: 'ajax',
		url: '/cgxjd/pageInquiry',
//			enablePaging: false,
		reader: {
			type: 'json',
			root: 'data',
			totalProperty: 'count'
		}
	},
	listeners:{
		datachanged:function(store,opts){                                                        
			//alert("我重新加载了数据");
			var mainTabs = Ext.getCmp('mainTabs');
			var currTab = mainTabs.getActiveTab();
			var currForm = currTab.down('form').getForm().loadRecord(store.data.items[0]);
			//alert(Ext.encode(store.data.items[0].raw));
			currTab.down("grid").getStore().loadData(store.data.items[0].raw.purchaseInquiryDetails);
//			var datas = store.data;   
//			for(var i=0;i<datas.length;i++){
//				alert(Ext.encode(datas.get(i).data));
//			}
			
//			currTab.down('grid').getStore().removeAll();
//			currTab.down('grid').getStore().add(store.data.items[0].purchaseInquiryDetailModel);
			//Ext.pluck(activeTab.down('grid').setStore().data.items[0].PurchaseiInquiryDetail,'data')
			//var currGrid = currTab.down('grid').getForm().loadRecord(store.data.items[0].PurchaseiInquiryDetail);
		}
	},
	render:function(){
		var mainTabs=Ext.getCmp("mainTabs");
		var currTab=mainTabs.getActiveTab();
		var currForm=currTab.down("form").getForm().loadRecord(store.data.items[0]);
		//var currGrid = currTab.down('grid').getForm().loadRecord(store.data.items[0].PurchaseiInquiryDetail);
	}
});

